#ifndef GAMEAPP_H
#define GAMEAPP_H

#include <OISEvents.h>
#include <OISInputManager.h>
#include <OISKeyboard.h>
#include <OISMouse.h>
#include <OgreWindowEventUtilities.h>

#include "GameView.h"
#include "GameEventManager.h"
#include "GameLogic.h"
#include "GameAudio.h"
#include "GameInput.h"

enum GameState
{
	State_Initializing,
	State_Starting,
	State_Loading,
	State_Running,
	State_Reseting,
	State_Pause,
	State_Quitting,
	State_GameOver,
	State_LoadGame
};

class GameApp :
	public Ogre::WindowEventListener,
	public Ogre::FrameListener
{
public:
	GameApp(void);
	~GameApp(void);
	bool initApp(void);
	bool startApp(void);
	// Ogre::WindowEventListener
	virtual bool frameRenderingQueued(const Ogre::FrameEvent& evt);
	// Ogre::WindowEventListener
	virtual void windowResized(Ogre::RenderWindow* rw);
	virtual void windowClosed(Ogre::RenderWindow* rw);
	GameState getState(void) const;
	void changeState(GameState state);
	void setTimeFactor(const float factor);
	const float getTimeFactor(void) const;

	GameLogic *mpGameLogic;
	//GameOptions *mpGameOptions;
	GameView *mpView;
	GameAudio *mpAudio;
	//LuaManager *mpLuaManager;
	GameEventManager *mpEventManager;
	GameInput *mpInput;
private:
	// Time in milliseconds for the event manager
	static const unsigned long TIME_EVENT_MANAGER = 10;

	GameState mState;
	// Time of the last frame
	unsigned long mLastTime;
	// Game speed
	float mfTimeFactor;
};

extern GameApp *gpApp;

#endif